package cn.rongdao.jrkabao.util.login;

import android.os.AsyncTask;

import com.mifengkong.frtools.util.FRToast;
import com.netease.nis.captcha.Captcha;

import java.lang.ref.WeakReference;

/**
 * Created by jiangyongxing on 2017/7/11.
 * 描述：
 */

public class LoginAsyncTask extends AsyncTask<Void, Void, Boolean> {

    private WeakReference<Captcha> mCaptchaWeakReference;

    LoginAsyncTask(Captcha mCaptcha) {
        mCaptchaWeakReference = new WeakReference<>(mCaptcha);
    }

    @Override
    protected Boolean doInBackground(Void... params) {
        //可选：简单验证DeviceId、CaptchaId、Listener值
        return mCaptchaWeakReference.get().checkParams();
    }

    @Override
    protected void onPostExecute(final Boolean success) {
        if (success) {
            //必填：开始验证
            mCaptchaWeakReference.get().Validate();
        } else {
            FRToast.showToastSafe("验证码SDK参数设置错误,请检查配置");
        }
    }
}